$(function () {
    findCuisineALL();
})

function findCuisineALL() {
    $.ajax({
        url: '/CuisineFindAll',
        data: '',
        type: 'get',
        dataType: 'json',
        success: function (data) {
            setCuisineData(data[0].object);
        }
    })
}

function setCuisineData(data) {

    for (let i = 0; i < data.length; i++) {
        $("#cuisine").append("<option value='" + data[i].id + "'>" + data[i].title + "</option>")
    }
}

function save() {
    let data = new FormData();
    data.append("cuisine", $("#cuisine").val());
    data.append("title", $.trim($("#title").val()));
    data.append("price", $.trim($("#price").val()));
    data.append("content", $("#content").val());
    data.append("imgHref", $("#imgHref")[0].files[0]);
    // let data = {title: $("#title").val()};
    $.ajax({
        url: '/productAdd',
        data: data,
        type: 'post',
        dataType: 'json',
        contentType : false,
        processData : false,
        success: function (data) {
            $('#right').load('/back/productFindAll.jsp');
        }
    })
}